package Model;

import java.util.Scanner;
import java.io.*;

/**
 *
 * @author pol
 */
public class Driver {

    /**
     * empty constructor
     */
    public Driver() {
    }

    /**
     *
     * @param n driver name
     * @param cd class of the driver
     * @param e experience of the driver
     * @param s salary of the driver
     */
    public Driver(String n, String cd, int e, double s) {
        name = n;
        classDriver = cd;
        experience = e;
        salary = s;
    }

    /**
     *
     * @return the name of the driver
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @return salary of the driver
     */
    public double getSalary() {
        return salary;
    }

    /**
     *
     * @return class of the driver
     */
    public String getClassDriver() {
        return classDriver;
    }

    /**
     *
     * @return experience of driver
     */
    public int getExperience() {
        return experience;
    }

    /**
     * Writing data about drivers
     *
     * @param out class PrintWriter
     */
    public void writeData(PrintWriter out) {
        out.println(name + "|" + classDriver + "|" + experience + "|" + salary);
    }

    /**
     * Reading data about driver from Scanner
     *
     * @param in class Scanner
     */
    public void readData(Scanner in) {
        String line = in.nextLine();
        String[] tokens = line.split("\\|");
        name = tokens[0];
        classDriver = tokens[1];
        experience = Integer.parseInt(tokens[2]);
        salary = Double.parseDouble(tokens[3]);
    }

    /**
     * Return Info about Driver in String form
     *
     * @return
     */
    public String toString() {
        return "[Name = " + name + ", Driver class = " + classDriver
                + ", Experience = " + experience + ", Salary = " + salary + "]";
    }
    // TODO write FIO of driver and some getter's 
    private String name;
    private String classDriver;
    private int experience;
    private double salary;
}
